{% extends '::base.html.twig' %}

{% block title %}Survey{% endblock %}
{% block body %}{%block content %}
    <h1>Lista zaproszeń</h1>

    <table class="records_list table table-striped table-hover">
        <thead>
            <tr>
                <th>Id</th>
                <th>Survey</th>
                <th>Name</th>
                <th>Surname</th>
                <th>Email</th>
                <th>Token</th>
                <th>Filled</th>
                <th>Result</th>
                <th>Comparisons</th>
                <th>Link</th>
                <th>Actions</th>
            </tr>
        </thead>
        <tbody>
        {% for entity in entities %}
            <tr>
                <td><a href="{{ path('invitation_show', { 'id': entity.id }) }}">{{ entity.id }}</a></td>
                <td>{{ entity.survey }}</td>
                <td>{{ entity.name }}</td>
                <td>{{ entity.surname }}</td>
                <td>{{ entity.email }}</td>
                <td>{{ entity.token }}</td>
                <td>{{ entity.filled }}</td>
                <td>
                    {% if entity.result %}
                        {{entity.result.resultArray|slice(0, 10)}}
                    {% endif %}
                </td>
                <td>
                    {{entity.comparisons|length}}
                    {#{% for comp in entity.comparisons %}
                        {{comp.product1.name}} vs {{comp.product2.name}} {{comp.result}} <br />
                    {%endfor%}#}
                </td>
                <td><a href="{{ path('product_compare', { 'survey_id': entity.survey.id, 'invitation_id': entity.id, 'compareStep':1, 'token_hash':entity.token}) }}">show</a></td>
                <td>
                <ul>
                    <li>
                        <a href="{{ path('invitation_show', { 'id': entity.id }) }}">Pokaż</a>
                    </li>
                    <li>
                        <a href="{{ path('invitation_edit', { 'id': entity.id }) }}">Edytuj</a>
                    </li>
                </ul>
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>

        <ul>
        <li>
            <a href="{{ path('invitation_new') }}">
                Create a new entry
            </a>
        </li>
    </ul>{% endblock %}
    {% endblock %}
